package top.humbleyuan.double_pointer;

/**
 * @Author HumbleYuan
 * @Date 2020/5/18 15:46
 * @Des 盛最多的水
 *      双指针：
 *      两指针从两端向中间靠，每次移动高度低的指针
 */
public class LeetCode_11 {
    public static void main(String[] args) {
        int[] height = {1,3,2,5,25,24,5};

        int pre = 0;
        int back = height.length - 1;
        int max = 0;
        while(pre < back) {
            int area = Math.min(height[pre], height[back]) * (back - pre);
            max = max < area ? area : max;
            if(height[pre] < height[back] ) {
                pre ++;
            }else {
                back --;
            }
        }
        System.out.println(max);
    }
}
